package com.tfjybj.itoo.teach.provider.facade;

import org.apache.dubbo.config.annotation.Service;
import com.github.pagehelper.PageInfo;
import com.tfjybj.itoo.teach.FacadeApi.AcademyApi;
import com.tfjybj.itoo.teach.entity.AcademyEntity;
import com.tfjybj.itoo.teach.model.AcademyModel;
import com.tfjybj.itoo.teach.provider.service.AcademyService;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by QZS on 2019/4/27.
 */
@Service
@org.springframework.stereotype.Service
public class AcademyFacade implements AcademyApi {
    @Resource
    AcademyService academyService;

    /**
     * 查询所有Academy
     * @author 杨燕梅
     * @since 2.0.0 2018-11-23 11:52:12
     */
    @Override
    public List<AcademyModel> queryAllAcademy(){
        return academyService.queryAllAcademy();
    }

    /**
     * 添加
     *
     * @param academyEntity AcademyEntity
     * @return 添加的结果（修改，加入判重，设置默认type）
     * @author 智雪艳
     * @since 2.0.0 2019-05-23 14:13:09
     */
    @Override
    public boolean create(AcademyEntity academyEntity) {
        return academyService.save(academyEntity);
    }

    /**
     * 删除
     *
     * @param id 主键id
     * @return ItooResult 是否删除成功
     * @author 智雪艳
     * @since 2.0.0 2019-05-23 14:13:09
     */
    @Override
    public boolean delete(String id) {
        academyService.removeById(id);
        return academyService.removeById(id);
    }

    /**
     * 批量删除
     *
     * @param ids ids
     * @return ItooResult 批量删除是否成功结果
     * @author 智雪艳
     * @since 2.0.0 2019-05-23 14:13:09
     */
    @Override
    public boolean deleteByIds(List<String> ids) {
        return academyService.removeByIds(ids);
    }

    /**
     * 修改
     *
     * @param academyEntity AcademyEntity
     * @return 修改后的结果
     * @author 智雪艳
     * @since 2.0.0 2019-05-23 14:13:09
     */
    @Override
    public boolean modify(AcademyEntity academyEntity) {
        academyService.updateById(academyEntity);
        return academyService.updateById(academyEntity);
    }

    /**
     * 根据id查找Academy
     *
     * @param id 主键id
     * @author 田成荣
     * @author 智雪艳
     * @since 2.0.0 2019-05-23 14:13:09
     */
    @Override
    public AcademyEntity findById(String id) {
        AcademyEntity academyEntity = academyService.getById(id);
        return academyEntity;
    }

    /**
     * 分页查询所有Academy
     *
     * @param pageNo   页码
     * @param pageSize 每页条数
     * @author 智雪艳
     * @since 2.0.0 2019-05-23 14:13:09
     */
    @Override
    public PageInfo<AcademyEntity> queryPageAll(Integer pageNo, Integer pageSize) {
        PageInfo<AcademyEntity> academys = academyService.queryPageAll(pageNo, pageSize);
        return academys;
    }

    /**
     * 根据机构名称模糊查询academy
     *
     * @param name     机构名称
     * @param pageNo   页码
     * @param pageSize 页数
     * @return 模糊查询的academy
     * @author 智雪艳
     * @since 2.0.0 2019-05-23 14:13:09
     */
    @Override
    public PageInfo<AcademyEntity> queryAcademyByLikeName(String name, Integer pageNo, Integer pageSize) {
        PageInfo<AcademyEntity> academyList = academyService.queryByLikeName(name, pageNo, pageSize);
        return academyList;
    }

    /**
     * 无参查询Academy表所有学院信息
     *
     * @author 智雪艳
     * @since 2.0.0 2019-05-23 14:13:09
     */
    @Override
    public List<AcademyEntity> findAcademy() {
        List<AcademyEntity> academyEntityList = academyService.findAcademy();
        return academyEntityList;
    }

    /**
     * 无参查询所有二级学院,去除没有专业的学院,附加专业数
     *
     * @return 二级学院集合
     * @author 智雪艳
     * @since 2.0.0 2019-05-23 14:13:09
     */
    @Override
    public List<AcademyModel> selAcademy() {
        List<AcademyModel> academyModelList = academyService.selAcademy();
        return academyModelList;
    }



}
